import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-10-30
 * Time: 16:30
 */
public class Test {
    public static Map<String, Integer> countWords(String[] words){
        Map<String, Integer> map = new HashMap<>();
        for(String word : words){
            if(map.get(word) == null){
                map.put(word, 1);
            }else {
                int val = map.get(word);
                map.put(word, val+1);
            }
        }
        return map;
    }

    public static void main1(String[] args) {
        String[] words = {"this", "dog", "cat", "cat", "this", "dog"};
        Map<String, Integer> map = countWords(words);
        Set<Map.Entry<String, Integer>> entryset = map.entrySet();
        for (Map.Entry<String, Integer> entry : entryset){
            System.out.println("Key: " + entry + "  Val: " + entry.getKey());
        }
    }

    public static int singleNumber(int[] nums){
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])){
                set.remove(nums[i]);
            }else{
                set.add(nums[i]);
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }

    public static void main2(String[] args) {
        int[] array = {1,2,3,4,1,2,3};
        System.out.println(singleNumber(array));
    }
        public static void func(String str1, String str2){
            str1 = str1.toUpperCase();
            str2 = str2.toUpperCase();

            HashSet<Character> setAct = new HashSet<>();
            for (int i = 0; i < str2.length(); i++) {
                char ch = str2.charAt(i);
                setAct.add(ch);
            }

            //第一步是把不同的数给挑出来，然后对于重复输出的数据给去重
            HashSet<Character> setBroken = new HashSet<>();
            for (int i = 0; i < str1.length(); i++) {
                char ch = str1.charAt(i);
                if(!setAct.contains(ch) && !setBroken.contains(ch)){
                    setBroken.add(ch);
                    System.out.print(ch);
                }
            }
        }

        public static void main(String[] args) {
            func("7_This_is_a_test", "_hs_s_a_es");
        }
    }
